package com.bigFuWengBackend.server.handler;

import com.alibaba.fastjson.JSON;
import com.bigFuWengBackend.entity.Constant;
import com.bigFuWengBackend.entity.Room;
import com.bigFuWengBackend.entity.User;
import com.bigFuWengBackend.entity.items.ItemsAllSendDTO;
import com.bigFuWengBackend.entity.login.LoginRecieveDTO;
import com.bigFuWengBackend.entity.login.LoginSendDTO;
import com.bigFuWengBackend.entity.room.JoinRoomRecDTO;
import com.bigFuWengBackend.entity.room.JoinRoomSendDTO;
import com.bigFuWengBackend.mapper.UserInfoMapper;

public class RoomHandler {
    public JoinRoomRecDTO userJoinRoom(String message, UserInfoMapper userInfoMapper){
        JoinRoomRecDTO recieve = JSON.parseObject(message, JoinRoomRecDTO.class);
        return recieve;
    }
    public String roomItemBuy(String message, UserInfoMapper userInfoMapper){
        LoginRecieveDTO recieve = JSON.parseObject(message, LoginRecieveDTO.class);
        User userInfo = userInfoMapper.getUserInfo(recieve.getData().getUserId());
        LoginSendDTO res = new LoginSendDTO();
        res.setType(Constant.LOGIN_TYPE);
        res.setData(userInfo);
        return JSON.toJSONString(res);
    }
    public String roomItemOnSell(String message, UserInfoMapper userInfoMapper){
        LoginRecieveDTO recieve = JSON.parseObject(message, LoginRecieveDTO.class);
        User userInfo = userInfoMapper.getUserInfo(recieve.getData().getUserId());
        LoginSendDTO res = new LoginSendDTO();
        res.setType(Constant.LOGIN_TYPE);
        res.setData(userInfo);
        return JSON.toJSONString(res);
    }

    public String roomUserDied(String message, UserInfoMapper bean) {
        return "";
    }

    public String roomUserExit(String message, UserInfoMapper bean) {
        return "";
    }
}
